﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation.Validators;

namespace BussinessLogicTecnoPez.Produccion.Compras
{
    [Serializable]
    [DBTable("FACTORESOFERTAS")]
    public class FactorOfertaProveedor : EntityBase<FactorOfertaProveedor>
    {
        private Factor objFactor;
        private decimal valor;

        public FactorOfertaProveedor()
        {
            this.Factor = null;
            this.Valor = 0;
        }

        public FactorOfertaProveedor(Factor objFactor, decimal valorFactor)
        {
            this.Factor = objFactor;
            this.Valor = valorFactor;
        }

        [NotNullValidator(MessageTemplate = "Factor: debe tener algún valor.")]
        [FriendlyName("Factor", true)]
        [DBField("IDFACTOR", true, false, true, "IDFACTOR")]
        public Factor Factor
        {
            get { return objFactor; }
            set { objFactor = value; }
        }

        /// <summary>
        /// Utilizada para el manejo de las grillas
        /// </summary>
        [FriendlyName("IdFactor", false)]
        public int IdFactor
        {
            get
            {
                if (objFactor != null)
                    return objFactor.IdFactor;
                else
                    return 0;
            }
        }

        [FriendlyName("Tipo", false)]
        public string Tipo
        {
            get
            {
                if (objFactor != null)
                    return objFactor.Tipo;
                else
                    return string.Empty;
            }
        }

        [FriendlyName("Valor", true)]
        [DBField("VALOR", false, false)]
        public decimal Valor
        {
            get { return valor; }
            set { valor = value; }
        }
    }
}
